#ifndef ABSTRACTPIPE_H
#define ABSTRACTPIPE_H

#include <QObject>
#include<QGraphicsItem>

class AbstractPipe : public QObject,public QGraphicsItem
{
    Q_OBJECT
protected:
    float x,y,vx;
    bool isupper,Uncounted;
    static QImage PipeImg;
    virtual void updateXY()=0;
    virtual void afterUpdateXY();
public:
    AbstractPipe(QGraphicsScene&scene,
                 bool upper,
                 float y0=0,
                 float v0=3,
                 QObject *parent=0);
    AbstractPipe(float x0,float y0,
                 bool upper,float v0=3);
    ~AbstractPipe();
    void advance(int phase);
    QRectF boundingRect()const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr);
protected slots:
    virtual void onGameOver();
    virtual void onGameRestart();
    virtual void onGameBegin();
};

#endif // ABSTRACTPIPE_H
